package com.demo.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author gxd
 * @since 2025/6/1
 */
@Getter
@AllArgsConstructor
public enum UserStatusEnum {
    OK("0", "正常"),
    DISABLE("1", "停用");

    private final String code;
    private final String message;

    public String isOk(String code) {
        for (UserStatusEnum statusEnum : UserStatusEnum.values()) {
            if (ObjUtil.equals(statusEnum.getCode(), code)) {
                return statusEnum.getMessage();
            }
        }

        throw new RuntimeException("未通过当前code查询到合法的枚举类型code=" + code);
    }
}
